/**
 * Created by liguangsong on 16/8/13.
 */
import { SELECT_LAST, SELECT_NEXT, SELECT_PAGE, JUMP_PAGE } from '../action/select_page.js'

function getInitialState() {
    return {
        page: 1
    }
}

function selectPage(state=getInitialState(), action) {
    switch(action.type) {
        case SELECT_LAST: {
            var page = state.page - 1;
            return {
                page: page
            }
        }
        case SELECT_NEXT: {
            var page = state.page + 1;
            return {
                page: page
            }
        }
        case SELECT_PAGE: {
            var page = parseInt(action.page);
            return {
                page: page
            }
        }
        default : {
            return state;
        }
    }
}

export default selectPage;